<?php
// 本类由系统自动生成，仅供测试用途

//import("ORG.Util.Page");

class NewsAction extends Action{

	public function news(){

		//公告
		$News = new Model('News');
    	$news_id = (int)$_GET['news_id'];
		$news = $News->where('news_id='.$news_id)->find();

		//公告附件
		$Affix = new Model('Newsaffix');
		$affixes = $Affix->where('news_id='.$news_id)->findAll();

		$this->assign('affixes',$affixes);
		$this->assign('news',$news);
		$this->display();
    }

    //新闻列表
    public function  newsList(){

    	import("ORG.Util.Page");
    	$News = new Model('News');

    	$type = $_GET['type'];

    	switch ($type){
    		case 0:
    			$newsType = '学院要闻';
    			break;
    		case 1:
    			$newsType = '工作快讯';
    			break;
    		default:
    			$newsType = '学生风采';

    	}

    	$count = $News->where('type='.$type)->count();
    	$Page = new Page($count, 15);
    	$show = $Page->show();

    	$list = $News->where('type='.$type)->order('news_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();

    	$this->assign('type',$type);
    	$this->assign('newsType',$newsType);
    	$this->assign('newsList',$list);
    	$this->assign('page',$show);
    	$this->display();

    }

}
?>
